var t = require("../../../mybehaviors/location/location"), a = getApp();

Page({
    behaviors: [ t ],
    data: {
        show1: !0,
        show2: !0,
        wxTitie: "",
        PageNameList: {},
        location: {},
        data_info: {},
        hotel_introduce: "",
        showTotal: !1,
        exchangeButton: !0,
        showExchangeButton: !1,
        id: "",
        cityData: "",
        city: "",
        title: "",
        address: "",
        point: {
            lat: "",
            lng: ""
        },
        HOME_PAGE_URL: "plugin.hotel.frontend.hotel.get-hotel-info.get-info-by-hotel-id"
    },
    onLoad: function(t) {
        var a = this;
        t.id && this.setData({
            id: t.id
        }), t.city && this.setData({
            cityData: t.city
        }), this.getCustomizeHotelHead(), this._getLocation(function() {
            a.getHomePageData();
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getCustomizeHotelHead: function() {
        var t = this, e = "";
        try {
            var o = wx.getStorageSync("customizeHotelHead");
            o && (e = o);
        } catch (t) {}
        if (a._isTextEmpty(e)) {
            var i = a.getNetAddresss("plugin.hotel.frontend.hotel.get-hotel-info.get-custom-name");
            a._getNetWork({
                url: i,
                success: function(a) {
                    var e = a.data;
                    if (1 == e.result) {
                        t.setData({
                            PageNameList: e.data
                        }), wx.setNavigationBarTitle({
                            title: e.data.hotels ? e.data.hotels + "详情" : ""
                        });
                        try {
                            wx.setStorageSync("customizeHotelHead", JSON.stringify(e.data));
                        } catch (t) {
                            console.log(t);
                        }
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else this.setData({
            PageNameList: JSON.parse(e)
        }), wx.setNavigationBarTitle({
            title: this.data.PageNameList.hotels ? this.data.PageNameList.hotels + "详情" : ""
        });
    },
    getHomePageData: function() {
        var t = this, e = a.getNetAddresss(t.data.HOME_PAGE_URL);
        e += "&hotel_id=" + this.data.id, e += "&lng=" + this.data.point.lng, e += "&lat=" + this.data.point.lat, 
        e += "&city_name=" + this.data.cityData, a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 == e.result && t.setData({
                    data_info: e.data,
                    hotel_introduce: e.data.hotel_introduce
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    showTotalIntro: function() {
        this.setData({
            showTotal: !this.data.showTotal,
            exchangeButton: !this.data.exchangeButton
        });
    },
    toggleShow1: function() {
        this.setData({
            show1: !this.data.show1
        });
    },
    toggleShow2: function() {
        this.setData({
            show2: !this.data.show2
        });
    }
});